﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BeeZ.CommonObjects.Interfaces;
using BeeZ.Client.Hive;
using BeeZ.Client.Bees;
using BeeZ.Client.Bears;

namespace BeeZ.Client
{

    public static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        public static void Main()
        {
            Ignition.InitializeComponents();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }

    static class Ignition
    {

        //private IHive mainHive;
        private static IList<IBear> bears = new List<IBear>();


        public static void InitializeComponents()
        {
            InitializeBears();
            InitializeBees();
        }

        public static void Start()
        {
            MainHive.ResumeAll();
        }

        public static void Stop()
        {
            MainHive.PauseAll();
        }

        private static void InitializeBees()
        {

            //MainHive.RegisterBee(new SleepingBee(3, bears.Single(bear => bear is ConsoleBear)));
            //MainHive.RegisterBee(new SleepingBee(7, bears.Single(bear => bear is ConsoleBear), bears.Single(bear => bear is SendToServerBear)));
            MainHive.RegisterBee(new IdleBee(10, bears.Single(bear => bear is ConsoleBear), bears.Single(bear => bear is IdleBear), bears.Single(bear => bear is SendToServerBear)));
            MainHive.RegisterBee(new ForegroundBee(10, bears.Single(bear => bear is ConsoleBear), bears.Single(bear => bear is SendToServerBear)));

        }

        private static void InitializeBears()
        {
            IBear b = new SendToServerBear();
            b.AddPolicy(new SameAsLastPolicy());
            bears.Add(b);
            bears.Add(new IdleBear());
            bears.Add(new ConsoleBear());
        }

    }

}